#[derive(Debug)]
struct Person {
    name: String,
    age: u8,
}
#[derive(Debug)]
struct Uint;

struct Pair(i128, i128);

#[derive(Debug)]
struct Point {
    x: f64,
    y: f64,
}

#[allow(dead_code)]
#[derive(Debug)]
struct Rect {
    top_left: Point,
    bottom_right: Point,
}

//
fn main() {
    let name = String::from("P");
    let age = 27;
    let peter = Person { name, age };
    let point: Point = Point { x: 10.3, y: 0.4 };
    let bottom_right = Point { x: 5.2, ..point };
    println!("{:?}", bottom_right);

    let Point { x: left, y: top } = point;
    println!("left={:?} top={:?}", left, top);

    let r = Rect {
        top_left: Point { x: 10.3, y: 0.4 },
        bottom_right: Point { x: 5.2, y: -3.1 },
    };
    println!("rect={:?}", r);

    let uint = Uint;
    println!("{:?}", uint);

    let Pair(x, y) = Pair(10, 20);
    println!("x={:?} y={:?}", x, y);

    let a = area(&r);
    println!("area={:?}", a);

    let p = Point { x: 10.0, y: 10.0 };
    let s = square(&p, 10.0);
    println!("square={:?}", s);
}

fn area(rect: &Rect) -> f64 {
    (rect.top_left.x - rect.bottom_right.x) * (rect.top_left.y - rect.bottom_right.y)
}

fn square(p: &Point, f: f64) -> Rect {
    Rect {
        top_left: Point { ..*p },
        bottom_right: Point {
            x: p.x + f,
            y: p.y + f,
        },
    }
}
